#!/bin/bash
#
#
#   process results of test_60a and test_60b to create
#   data files of opening at the notch root
#   and the remote load (on the 1-degree slice).
#
#   write a logos input file that reads the data files
#   and makes a nice plot
#
#
#   warp3d output file names are test_60_a_out, test_60_b_out
#   The output commands in the warp3d runs
#   uses the "noheader" option to simplify processing here.
#
/bin/rm z* >& /dev/null
/bin/rm \#* >& /dev/null 
/bin/rm test_60_*results  >& /dev/null
/bin/rm test_60_logos*  >& /dev/null
#
#
#              test_60a
#
cp test_60_a_out zzout
#
#    keep only the lines with reaction totals. then strip
#    columns with y-reactions
#
grep 'Totals:  ' zzout > zqout
cut -c40-55 zqout >zforces
#
grep '     293         ' zzout > zqout1
cut -c40-55 zqout1 >zdispl
paste zdispl zforces  >test_60_a_results
#
#     add a 0 0 first data line
#
echo " 0.0 0.0 " >zzero
cat zzero test_60_a_results >z0
/bin/rm test_60_a_results
mv z0 test_60_a_results
#
#              test_60b
#
/bin/rm z* >& /dev/null
/bin/rm \#* >& /dev/null 
cp test_60_b_out zzout
#
#    keep only the lines with reaction totals. then strip
#    columns with y-reactions
#
grep 'Totals:  ' zzout > zqout
cut -c40-55 zqout >zforces
#
grep '     293         ' zzout > zqout1
cut -c40-55 zqout1 >zdispl
paste zdispl zforces  >test_60_b_results
#
#     add a 0 0 first data line
#
echo " 0.0 0.0 " >zzero
cat zzero test_60_b_results >z0
/bin/rm test_60_b_results
mv z0 test_60_b_results
#
#
#   write a logos input file to plot the results
#
cat > test_60_logos_input_file <<!!limitstring
c
c  logos input file to plot results for
c  test_60 (a and b)
c    
c
echo off
font 1
paper size 11.0 8.5
clip soft 2.0 10.0 1.5 7.5
map x -5 5 y -10 10
divi x  10 2  y 10 2
format x 0 y 0
char size .14 .667 20 
tic size .08 .04
pen color yellow
line thickness 2
origin x 0 y 0
draw x reflect
draw y reflect
char size .20 .667 0
subscript size 0.15
pen color cyan
xlabel 'notch opening (mils)'
ylabel 'remote load (kips)'
pen color yellow
line thickness 2
frame
line thickness 1
pen color magenta
c
data from file 'test_60_a_results'
column 1 * 2000 is x
column 2 * 360 is y
symbol ftriangle size 0.10
plot x y connect
c
data from file 'test_60_b_results'
column 1 * 2000 is x
column 2 * 360 is y
symbol ftriangle size 0.10
pen color red
line type 2
plot x y connect
c
line thickness 1
line type 1
font 1
pen color yellow
char size .14 .667
pen color magenta
pen color yellow  

character size 0.14 0.667 0
label start at 2.8 3.3 'Cyclic Plasticity'
legend start at 2.1 3.0
  pen color magenta line type 1 'nonlinear_hardening'
  pen color red line type 2 'generalized_plasticity'
end
c
pen color yellow
character size 0.16 0.667 0
label at 2.2 7.2 'Notched Round Bar'
character size 0.13 0.667 0
legend at 2.2 6.9
"0.5 in. dia., 2 in. length"
"Symmetric cycling to fixed"
"  remote displacement"
end
!!limitstring
#
#     cleanup
#
#
/bin/rm z* >& /dev/null
/bin/rm \#* >& /dev/null

